package sc.hibernate.models;

import java.util.*;
import javax.persistence.*;

/**
 * Hibernate model entity for company
 * 
 *  A sector belongs to many sectors
 *  A company has many quotes
 * 
 * @author Cédric Rais
 *
 */
@Entity
@Table( name = "company" )
public class Company {
	
	@Id
	private String symbol;
	private String name;
	
	@Column( name="52_WEEK_LOW")
	private Float week_low_52;
	@Column( name="52_WEEK_HIGH")
	private Float week_high_52;
	private Integer shares;
	private Float pe_ratio;
	private Float peg_ratio;
	private Float short_ratio;
	private Float roe_ratio;
	private Float current_ratio;
	private Float book_value_ratio;
	private Float inventory_turnover_ratio;
	
	@ManyToMany
	@JoinTable(name="comp_sec",
				joinColumns={@JoinColumn(name="SYMBOL")},
				inverseJoinColumns={@JoinColumn(name="SEC_ID")})
	private Set<Sector> sectors = new HashSet<Sector>();
	
	@OneToMany(targetEntity=Quote.class, mappedBy ="company")
	private Set<Quote> quotes = new HashSet<Quote>();
	
	public Company(){}
	
	public Company(String symbol, String name){
		this.symbol = symbol;
		this.name = name;
	}
	
	public Company(String symbol, String name, Float week_low_52,
			Float week_high_52, Float pe_ratio, Float peg_ratio,
			Float short_ratio, Float book_value_ratio) {
		this.symbol = symbol;
		this.name = name;
		this.week_low_52 = week_low_52;
		this.week_high_52 = week_high_52;
		this.pe_ratio = pe_ratio;
		this.peg_ratio = peg_ratio;
		this.short_ratio = short_ratio;
		this.book_value_ratio = book_value_ratio;
	}

	//--------------------------------------------------------------------------
	// Primary Key
	//--------------------------------------------------------------------------
	public String getSymbol() {
		return symbol;
	}
	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}
	
	//--------------------------------------------------------------------------
	// Associations
	//--------------------------------------------------------------------------
	public Set<Quote> getQuotes(){
		return quotes;
	}
	public void setQuotes(Set<Quote> quotes) {
		this.quotes = quotes;
	}
	
	public Set<Sector> getSectors() {
		return sectors;
	}
	public void setSectors(Set<Sector> sectors) {
		this.sectors = sectors;
	}

	//--------------------------------------------------------------------------
	// Fields
	//--------------------------------------------------------------------------
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public Float getWeek_low_52() {
		return week_low_52;
	}
	public void setWeek_low_52(Float week_low_52) {
		this.week_low_52 = week_low_52;
	}
	
	public Float getWeek_high_52() {
		return week_high_52;
	}
	public void setWeek_high_52(Float week_high_52) {
		this.week_high_52 = week_high_52;
	}
	
	public Integer getShares() {
		return shares;
	}
	public void setShares(Integer shares) {
		this.shares = shares;
	}
	
	public Float getPe_ratio() {
		return pe_ratio;
	}
	public void setPe_ratio(Float pe_ratio) {
		this.pe_ratio = pe_ratio;
	}
	
	public Float getPeg_ratio() {
		return peg_ratio;
	}
	public void setPeg_ratio(Float peg_ratio) {
		this.peg_ratio = peg_ratio;
	}
	
	public Float getShort_ratio() {
		return short_ratio;
	}
	public void setShort_ratio(Float short_ratio) {
		this.short_ratio = short_ratio;
	}
	
	public Float getRoe_ratio() {
		return roe_ratio;
	}
	public void setRoe_ratio(Float roe_ratio) {
		this.roe_ratio = roe_ratio;
	}
	
	public Float getCurrent_ratio() {
		return current_ratio;
	}
	public void setCurrent_ratio(Float current_ratio) {
		this.current_ratio = current_ratio;
	}
	
	public Float getBook_value_ratio() {
		return book_value_ratio;
	}
	public void setBook_value_ratio(Float book_value_ratio) {
		this.book_value_ratio = book_value_ratio;
	}
	
	public Float getInventory_turnover_ratio() {
		return inventory_turnover_ratio;
	}
	public void setInventory_turnover_ratio(Float inventory_turnover_ratio) {
		this.inventory_turnover_ratio = inventory_turnover_ratio;
	}
	
	//--------------------------------------------------------------------------
	// Others
	//--------------------------------------------------------------------------
	public String toString(){
		return symbol + ", " + name;
	}
}
